package be.jprojects.subscription.gui.i18n;


import java.awt.BorderLayout;
import java.awt.Component;
import java.util.ArrayList;

import javax.swing.JTabbedPane;

import be.jprojects.subscription.controllers.LanguageController;
import be.jprojects.subscription.controllers.ListenersController;
import be.jprojects.subscription.gui.listeners.SelectedLanguageChangeListener;



public class TranslatableTabbedPane extends JTabbedPane implements SelectedLanguageChangeListener {
	
	ArrayList<String> titles = new ArrayList<String>();

	public TranslatableTabbedPane() {
		super();
		setFocusable(false);
		ListenersController.getInstance().addLanguageChangeListener(this);
	}
	
	
	
	public Component add(String name, Component comp) {
		super.add(LanguageController.getInstance().translate(name), comp);
		titles.add(name);
		return comp;
	}

	public void selectedLanguageChanged() {
		for (int i=0; i<titles.size(); i++) {
			setTitleAt(i,LanguageController.getInstance().translate((String)titles.get(i)));
		}
	}

}
